<?php

class ContactController extends Controller {
    
    public function actionIndex() {
        $this->render("index");
    }
    
    function actionContact() {
        $model = new Contact();
        $this->render("Contact", array(
            "model" => $model
        ));
    }
    
    function actionContactForm($id=NULL) {
        $model = new Contact();
        
        // Save
        if (!empty($_POST["Contact"])) {
            if (!empty($_POST["Contact"]["id"])) {
                $id = $_POST["Contact"]["id"];
                $model = Contact::model()->findByPk($id);
            }
            $model->_attributes = $_POST["Contact"];
            
            if ($model->save()) {
                $this->redirect(array("Contact/Contact"));
            }
        }
        
        // Render
        if (!empty($id)) {
            $model = Contact::model()->findByPk($id);
        }
        
        $this->render("ContactForm", array(
            "model" => $model
        ));
    }
    
    function actionContactDelete($id) {
        PaymentType::model()->deleteByPk($id);
        $this->redirect("index.php?r=Contact/Contact");
    }
    //End Config Table mt_payment_type

}

?>
